﻿/********************************************************************************************************************
* Author:	Christos Polydorou																						*
* Email:	std04237@di.uoa.gr																						*
* Purpose:	This script is used in order to create the stored procedure "usp_category_addentity" that deletes an	*
*			entity from a category.																					*
********************************************************************************************************************/

CREATE PROCEDURE [dbo].[usp_category_deleteentity]
	@entityid bigint
AS
	DELETE FROM [Entity-Attribute]					/* delete the values for all the attributes */
	WHERE [Entity-Attribute].entity = @entityid		/* of the entity							*/

	DELETE FROM Entities							/* delete the entity	*/
	WHERE Entities.id = @entityid
	
RETURN 0